package cn.tedu.weibo1.Controller;

import cn.tedu.weibo1.mapper.UserMapper;
import cn.tedu.weibo1.pojo.dto.UserDTO;
import cn.tedu.weibo1.pojo.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired(required = false)
    UserMapper mapper;
    @RequestMapping("/user/insert")
    public int insert(@RequestBody UserDTO user){
        UserVO userVO=mapper.select(user.getUsername());
        if (userVO!=null) {
           return 2;
        }
        mapper.insert(user);
        return 1;
    }
}
